﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ShopPanel : MonoBehaviour
{
    public Button m_btnClose;

    public Button m_btnGoods1;
    public Button m_btnGoods2;
    public Button m_btnGoods3;
    public Button LoadAds;
    public GameObject wait_obj;
    public RewardedAdController ads;
    private int chongzhiIndex = 0;
    
    // Start is called before the first frame update
    void Start()
    {
        m_btnClose.onClick.AddListener(() =>
        {
            AudioManager.Instance.OnPlayClick();
            this.gameObject.SetActive(false);
            
        });

        LoadAds.onClick.AddListener(() =>
        {
            AudioManager.Instance.OnPlayClick();
            StartCoroutine(openwait());
            ads.LoadAd();
        });

        EventCenter.AddListener<string>(EventType.On_UPDATE_GOLD, OnUpdateGoldCoin);
    }
    private IEnumerator openwait()
    {
        wait_obj.gameObject.SetActive(true);
        yield return new WaitForSeconds(2f);
        wait_obj.gameObject.SetActive(false);
    }


    private void OnUpdateGoldCoin(string gold)
    {
        chongzhiIndex = 0;
    }
    
    private void OnDestroy()
    {
        EventCenter.RemoveListener<string>(EventType.On_UPDATE_GOLD, OnUpdateGoldCoin);
    }
}
